<p style='color:Blue'> What does <b>inheritance</b> in the hierarchical structure mean? <p>
<div style='border: 1px solid black'> <div style='margin: 20px; border: 10px solid blue; padding: 20px; background-color:Gray; font-size:150%;'> <div style='border: 1px solid black'> <span style='background-color:Green'>Hmmm</span> <p style='background-color:Red'>Amazing!</p> <span style='background-color:Yellow'>Another span</span> <a href='//cs.tru.ca' target='_blank' style='background-color:Cyan'>CS.TRU.CA</a> </div> </div> </div>
<div style='border: 2px blue solid'> <p style='width: 400px; border: 2px black solid''> Strike while the iron is hot. </p> <span style='border: 2px green solid'> Too many cooks spoil the broth. <div style='border: 2px yellow solid; width: 400px;'> You can't have your cake and eat it too. </div> Many hands make light work. </span> <span style='border: 2px black solid; width:400px'> When in Rome, do as the Romans do. </span> <p style='border: 2px black solid; width=50%'> Don't cross the bridge until you come to it. </p> <span> <-- Will it be displayed at the side of the above paragraph? --> Honesty is the best policy. </span> </div>
P: Strike while the iron is hot.
SPAN: Too many cooks spoil the broth.P: Don't cross the bridge until you come to it.
SPAN: Honesty is the best policy.<div style='border: 2px blue solid'> DIV: <span> SPAN: The grass is always greener on the other side of the fence. <span style='display:inline-block; border: 2px yellow solid; width: 250px; text-align: center'> SPAN: CS, TRU </span> Don't judge a book by its cover. <span> </div>
"This sentence will be disappered when the button is clicked."
document.getElementById(...)....
<div style='border:1px solid black'> <p> Positioning examples: </p> <!--You can try the next code yourself.--> <!-- No position value in the next div -> It follows the natural flow. --> <div style='position:relative; width:400px; height:200px; border:1px solid black;'> <div style='position:absolute; top:10px; right: -50px; width:250px; height:100px; border:2px solid blue;'></div> <div style='position:relative; top:50px; left: 50px; width:250px; height:100px; border:2px solid green;'> <p style='position:relative; left:25px; top:5px; width:100px; margin:0px; text-align:center; border:2px solid red;'> Interesting! </p> Ahhhhhhh <!-- In the next <p>, top is not specified. -> The natural flow is used for the top value. It is confusing. It might be better to use two position values, such as top&left, top&right, bottom&left, or bottom&right. --> <p style='position:absolute; left:50px; width:100px; margin:0px; text-align:center; border:2px solid yellow;'> Hmmmmm </p> </div> </div> </div>
Positioning examples:
Interesting!
AhhhhhhhHmmmmm
document.getElementById('...');
document.getElementsByTagName('...');
document.querySelectorAll("...");
htmlElementObj.innerHTML
htmlElementObj.setAttribute(), .getAttribute(), .style.setProperty(), .style.getProperty()
;.style.setProperty('background-color', 'Cyan')
htmlElementObj.attribute
, .style.property
; .style.backgroundColor = 'Cyan';
.style.backgroundColor = "Red";
htmlElementObj.addEventListener("event-name", function() { ... });
document.getElementById(...).style
object in JavaScript.
Default values as well.
window.getComputedStyle(htmlElementObj).cssProperty
should be used, even for default values.htmlElementObj
is visible, htmlElementObj.clientWidth
and .clientHeight
give numbers of pixels. E.g., 100, not "100px".
You may read The HTML DOM Element Object.
<style> #testcssjs { display: none; } </style> <div id='testcssjs'> Hmmm </div> <script> alert("1. " + document.???('testcssjs').???.display); // Nothing displayed because 'display' is not specified with the style attribute. alert("2. " + ????(document.getElementById('testcssjs')).???); // 'none' displayed document.getElementById('testcssjs').style.display = 'block'; alert("3. " + document.getElementById('testcssjs').style.display); // 'block' displayed alert("4. " + document.getElementById('testcssjs').style.height); alert("5. " + ????(document.getElementById('testcssjs')).display); // ??? displayed alert("6. " + ????(document.getElementById('testcssjs')).height); // "24px" alert("7. " + document.getElementById('testcssjs').clientHeight); // 24, not "24px" </script>